<template>
<table>
    <tr>
        <td>门店名称</td>
        <td>
            <input type="text" v-model="info.Name" placeholder="请输入门店名称">
        </td>
    </tr>
    <tr>
        <td>分店名称</td>
        <td>
            <input type="text" v-model="info.FdName" placeholder="请输入分店名称">
        </td>
    </tr>
    <tr>
        <td>门店电话</td>
        <td>
            <input type="text" v-model="info.Phone" placeholder="请输入门店电话">
        </td>
    </tr>
    <tr>
        <td>门店地址</td>
        <td>
            <input type="text" v-model="info.AddRess" placeholder="请输入门店地址">
        </td>
    </tr>
    <tr>
        <td>交通信息</td>
        <td>
            <input type="text" v-model="info.Jtinfo" placeholder="请输入交通信息">
        </td>
    </tr>
    <tr>
        <td>状态</td>
        <td>
            <input type="radio" v-model="info.Status" :value="true">营业中
            <input type="radio" v-model="info.Status" :value="false">已歇业
        </td>
    </tr>
    <tr>
        <td></td>
        <td>
            <input type="button"  value="门店添加" @click="Saveadd">
        </td>
    </tr>
</table>
</template>

<script setup lang="ts">
import {onMounted,ref} from 'vue'
import {useRoute,useRouter} from 'vue-router'
import axios from 'axios';


const info=ref({
 
  "Name": "",
  "FdName": "",
  "Phone": "",
  "AddRess": "",
  "Jtinfo": "",
  "Status": true
})

const Saveadd=()=>{
if(info.value.Name==""){
    alert("门店名称不能为空");
return;
}

if(info.value.Phone==""){
    alert("门店电话不能为空");
return;
}
if(info.value.Jtinfo==""){
    alert("门店交通不能为空");
return;
}
if(info.value.AddRess==""){
    alert("门店地址不能为空");
return;
}
axios.post("https://localhost:7224/api/Shop/AddShop",info.value)
.then(res=>{
    if(res.data>0){
        alert("添加成功");

    }else if(res.data==-1){
        alert("门店名称已存在不能重复添加");
    }else{
        alert("添加失败");
    }
})

}
</script>

<style scoped>

</style>